package com.yfp.machine.service.impl;

import com.yfp.machine.domain.Route;
import com.yfp.machine.mapper.RouteMapper;
import com.yfp.machine.service.RouteService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

import java.util.List;

/**
 * 线路表(Route)表服务实现类
 *
 *
 * @since 2023-12-21 20:49:53
 */
@Service("routeService")
public class RouteServiceImpl implements RouteService {
    @Resource
    private RouteMapper routeMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param routeId 主键
     * @return 实例对象
     */
    @Override
    public Route queryById(String routeId) {
        return this.routeMapper.queryById(routeId);
    }

    /**
     * 分页查询
     *
     * @param route 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Route> queryByPage(Route route) {
        return this.routeMapper.queryAllByLimit(route);
    }

    /**
     * 新增数据
     *
     * @param route 实例对象
     * @return 实例对象
     */
    @Override
    public Route insert(Route route) {
        this.routeMapper.insert(route);
        return route;
    }

    /**
     * 修改数据
     *
     * @param route 实例对象
     * @return 实例对象
     */
    @Override
    public Route update(Route route) {
        this.routeMapper.update(route);
        return this.queryById(route.getRouteId());
    }
}
